package com.tanhua.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.model.domain.Analysis;
import com.tanhua.model.vo.DataPointVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AnalysisMapper extends BaseMapper<Analysis> {
    /**
     * 累计用户
     * @return
     */
    @Select("select sum(num_registered) from tb_analysis_by_day")
    Integer queryCumulativeUsers();

    /**
     * 新增用户,活跃用户,次日留存率
     * @param startDate
     * @param endDate
     * @param column
     * @return
     */
    @Select("select date_format(record_date , '%Y-%m-%d') title , ${column} amount from tb_analysis_by_day where record_date between #{startDate} and #{endDate}")
    List<DataPointVo> thisYearStartDate(@Param("startDate") String startDate,
                                        @Param("endDate") String endDate,
                                        @Param("column") String column);
}
